


<!DOCTYPE html>
<html id="htmlId">
<head>
  <title>Coverage Report > SpriteTest</title>
  <style type="text/css">
    @import "../../css/coverage.css";
    @import "../../css/highlight-idea.css";
  </style>
  <script type="text/javascript" src="../../js/highlight.pack.js"></script>
</head>

<body>
<div class="content">
<div class="breadCrumbs">
Current scope:     <a href="../../index.html">all classes</a>
    <span class="separator">|</span>
    <a href="../index.html">nl.tudelft.jpacman.sprite</a>
</div>

<h1>Coverage Summary for Class: SpriteTest (nl.tudelft.jpacman.sprite)</h1>

<table class="coverageStats">
<tr>
  <th class="name">Class</th>
<th class="coverageStat 
">
  Class, %
</th>
<th class="coverageStat 
">
  Method, %
</th>
<th class="coverageStat 
">
  Line, %
</th>
</tr>
<tr>
  <td class="name">SpriteTest</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/1)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/11)
  </span>
</td>
<td class="coverageStat">
  <span class="percent">
    0%
  </span>
  <span class="absValue">
    (0/17)
  </span>
</td>
</tr>

</table>

<br/>
<br/>


<pre>
<div class="sourceCode" id="sourceCode"><i class="no-highlight">1</i>&nbsp;package nl.tudelft.jpacman.sprite;
<i class="no-highlight">2</i>&nbsp;
<i class="no-highlight">3</i>&nbsp;import static org.assertj.core.api.Assertions.assertThatThrownBy;
<i class="no-highlight">4</i>&nbsp;import static org.assertj.core.api.Assertions.assertThat;
<i class="no-highlight">5</i>&nbsp;
<i class="no-highlight">6</i>&nbsp;import java.io.IOException;
<i class="no-highlight">7</i>&nbsp;
<i class="no-highlight">8</i>&nbsp;import org.junit.jupiter.api.BeforeEach;
<i class="no-highlight">9</i>&nbsp;import org.junit.jupiter.api.Test;
<i class="no-highlight">10</i>&nbsp;
<i class="no-highlight">11</i>&nbsp;/**
<i class="no-highlight">12</i>&nbsp; * Verifies the loading of sprites.
<i class="no-highlight">13</i>&nbsp; *
<i class="no-highlight">14</i>&nbsp; * @author Jeroen Roosen 
<i class="no-highlight">15</i>&nbsp; */
<i class="no-highlight">16</i>&nbsp;@SuppressWarnings(&quot;magicnumber&quot;)
<b class="nc"><i class="no-highlight">17</i>&nbsp;public class SpriteTest {</b>
<i class="no-highlight">18</i>&nbsp;
<i class="no-highlight">19</i>&nbsp;    private Sprite sprite;
<i class="no-highlight">20</i>&nbsp;    private SpriteStore store;
<i class="no-highlight">21</i>&nbsp;
<i class="no-highlight">22</i>&nbsp;    private static final int SPRITE_SIZE = 64;
<i class="no-highlight">23</i>&nbsp;
<i class="no-highlight">24</i>&nbsp;    /**
<i class="no-highlight">25</i>&nbsp;     * The common fixture of this test class is
<i class="no-highlight">26</i>&nbsp;     * a 64 by 64 pixel white sprite.
<i class="no-highlight">27</i>&nbsp;     *
<i class="no-highlight">28</i>&nbsp;     * @throws java.io.IOException
<i class="no-highlight">29</i>&nbsp;     *      when the sprite could not be loaded.
<i class="no-highlight">30</i>&nbsp;     */
<i class="no-highlight">31</i>&nbsp;    @BeforeEach
<i class="no-highlight">32</i>&nbsp;    public void setUp() throws IOException {
<b class="nc"><i class="no-highlight">33</i>&nbsp;        store = new SpriteStore();</b>
<b class="nc"><i class="no-highlight">34</i>&nbsp;        sprite = store.loadSprite(&quot;/sprite/64x64white.png&quot;);</b>
<i class="no-highlight">35</i>&nbsp;    }
<i class="no-highlight">36</i>&nbsp;
<i class="no-highlight">37</i>&nbsp;    /**
<i class="no-highlight">38</i>&nbsp;     * Verifies the width of a static sprite.
<i class="no-highlight">39</i>&nbsp;     */
<i class="no-highlight">40</i>&nbsp;    @Test
<i class="no-highlight">41</i>&nbsp;    public void spriteWidth() {
<b class="nc"><i class="no-highlight">42</i>&nbsp;        assertThat(sprite.getWidth()).isEqualTo(SPRITE_SIZE);</b>
<i class="no-highlight">43</i>&nbsp;    }
<i class="no-highlight">44</i>&nbsp;
<i class="no-highlight">45</i>&nbsp;    /**
<i class="no-highlight">46</i>&nbsp;     * Verifies the height of a static sprite.
<i class="no-highlight">47</i>&nbsp;     */
<i class="no-highlight">48</i>&nbsp;    @Test
<i class="no-highlight">49</i>&nbsp;    public void spriteHeight() {
<b class="nc"><i class="no-highlight">50</i>&nbsp;        assertThat(sprite.getHeight()).isEqualTo(SPRITE_SIZE);</b>
<i class="no-highlight">51</i>&nbsp;    }
<i class="no-highlight">52</i>&nbsp;
<i class="no-highlight">53</i>&nbsp;    /**
<i class="no-highlight">54</i>&nbsp;     * Verifies that an IOException is thrown when the resource could not be
<i class="no-highlight">55</i>&nbsp;     * loaded.
<i class="no-highlight">56</i>&nbsp;     *
<i class="no-highlight">57</i>&nbsp;     * @throws java.io.IOException
<i class="no-highlight">58</i>&nbsp;     *             since the sprite cannot be loaded.
<i class="no-highlight">59</i>&nbsp;     */
<i class="no-highlight">60</i>&nbsp;    @Test
<i class="no-highlight">61</i>&nbsp;    public void resourceMissing() throws IOException {
<b class="nc"><i class="no-highlight">62</i>&nbsp;        assertThatThrownBy(() -&gt; store.loadSprite(&quot;/sprite/nonexistingresource.png&quot;))</b>
<b class="nc"><i class="no-highlight">63</i>&nbsp;            .isInstanceOf(IOException.class);</b>
<i class="no-highlight">64</i>&nbsp;    }
<i class="no-highlight">65</i>&nbsp;
<i class="no-highlight">66</i>&nbsp;    /**
<i class="no-highlight">67</i>&nbsp;     * Verifies that an animated sprite is correctly cut from its base image.
<i class="no-highlight">68</i>&nbsp;     */
<i class="no-highlight">69</i>&nbsp;    @Test
<i class="no-highlight">70</i>&nbsp;    public void animationWidth() {
<b class="nc"><i class="no-highlight">71</i>&nbsp;        AnimatedSprite animation = store.createAnimatedSprite(sprite, 4, 0,</b>
<i class="no-highlight">72</i>&nbsp;            false);
<b class="nc"><i class="no-highlight">73</i>&nbsp;        assertThat(animation.getWidth()).isEqualTo(16);</b>
<i class="no-highlight">74</i>&nbsp;    }
<i class="no-highlight">75</i>&nbsp;
<i class="no-highlight">76</i>&nbsp;    /**
<i class="no-highlight">77</i>&nbsp;     * Verifies that an animated sprite is correctly cut from its base image.
<i class="no-highlight">78</i>&nbsp;     */
<i class="no-highlight">79</i>&nbsp;    @Test
<i class="no-highlight">80</i>&nbsp;    public void animationHeight() {
<b class="nc"><i class="no-highlight">81</i>&nbsp;        AnimatedSprite animation = store.createAnimatedSprite(sprite, 4, 0,</b>
<i class="no-highlight">82</i>&nbsp;            false);
<b class="nc"><i class="no-highlight">83</i>&nbsp;        assertThat(animation.getHeight()).isEqualTo(64);</b>
<i class="no-highlight">84</i>&nbsp;    }
<i class="no-highlight">85</i>&nbsp;
<i class="no-highlight">86</i>&nbsp;    /**
<i class="no-highlight">87</i>&nbsp;     * Verifies that an split sprite is correctly cut from its base image.
<i class="no-highlight">88</i>&nbsp;     */
<i class="no-highlight">89</i>&nbsp;    @Test
<i class="no-highlight">90</i>&nbsp;    public void splitWidth() {
<b class="nc"><i class="no-highlight">91</i>&nbsp;        Sprite split = sprite.split(10, 11, 12, 13);</b>
<b class="nc"><i class="no-highlight">92</i>&nbsp;        assertThat(split.getWidth()).isEqualTo(12);</b>
<i class="no-highlight">93</i>&nbsp;    }
<i class="no-highlight">94</i>&nbsp;
<i class="no-highlight">95</i>&nbsp;    /**
<i class="no-highlight">96</i>&nbsp;     * Verifies that an split sprite is correctly cut from its base image.
<i class="no-highlight">97</i>&nbsp;     */
<i class="no-highlight">98</i>&nbsp;    @Test
<i class="no-highlight">99</i>&nbsp;    public void splitHeight() {
<b class="nc"><i class="no-highlight">100</i>&nbsp;        Sprite split = sprite.split(10, 11, 12, 13);</b>
<b class="nc"><i class="no-highlight">101</i>&nbsp;        assertThat(split.getHeight()).isEqualTo(13);</b>
<i class="no-highlight">102</i>&nbsp;    }
<i class="no-highlight">103</i>&nbsp;
<i class="no-highlight">104</i>&nbsp;    /**
<i class="no-highlight">105</i>&nbsp;     * Verifies that a split that isn&#39;t within the actual sprite returns an empty sprite.
<i class="no-highlight">106</i>&nbsp;     */
<i class="no-highlight">107</i>&nbsp;    @Test
<i class="no-highlight">108</i>&nbsp;    public void splitOutOfBounds() {
<b class="nc"><i class="no-highlight">109</i>&nbsp;        Sprite split = sprite.split(10, 10, 64, 10);</b>
<b class="nc"><i class="no-highlight">110</i>&nbsp;        assertThat(split).isInstanceOf(EmptySprite.class);</b>
<i class="no-highlight">111</i>&nbsp;    }
<i class="no-highlight">112</i>&nbsp;}
</div>
</pre>
</div>

<script type="text/javascript">
(function() {
    var msie = false, msie9 = false;
    /*@cc_on
      msie = true;
      @if (@_jscript_version >= 9)
        msie9 = true;
      @end
    @*/

    if (!msie || msie && msie9) {
        var codeBlock = document.getElementById('sourceCode');

        if (codeBlock) {
            hljs.highlightBlock(codeBlock);
        }
    }
})();
</script>

<div class="footer">
    
    <div style="float:right;">generated on 2022-05-22 18:55</div>
</div>
</body>
</html>
